<HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT>    package com.gwt.ss.client.loginable;<a name="line.1"></a>
<FONT color="green">002</FONT>    <a name="line.2"></a>
<FONT color="green">003</FONT>    /**<a name="line.3"></a>
<FONT color="green">004</FONT>     * Interface for asynchronous {@link com.google.gwt.user.client.rpc.RemoteService remoteService}<a name="line.4"></a>
<FONT color="green">005</FONT>     * descendants have chance to be wrapped as a {@link LoginableService}.&lt;br/&gt;<a name="line.5"></a>
<FONT color="green">006</FONT>     * example see blow:&lt;br/&gt; <a name="line.6"></a>
<FONT color="green">007</FONT>     * 非同步{@link com.google.gwt.user.client.rpc.RemoteService remoteService}繼承此<a name="line.7"></a>
<FONT color="green">008</FONT>     * Interface時，可被包裝成{@link LoginableService}&lt;br/&gt;<a name="line.8"></a>
<FONT color="green">009</FONT>     * 範例如下：&lt;br/&gt;&lt;br/&gt;<a name="line.9"></a>
<FONT color="green">010</FONT>     * <a name="line.10"></a>
<FONT color="green">011</FONT>     * &amp;#64;RemoteServiceRelativePath(&amp;quot;stockPrices&amp;quot;)&lt;br/&gt;<a name="line.11"></a>
<FONT color="green">012</FONT>     * public interface StockPriceService extends RemoteService {&lt;br/&gt;<a name="line.12"></a>
<FONT color="green">013</FONT>     * &amp;nbsp;&amp;nbsp;StockPrice[] getPrices(String[] symbols);&lt;br/&gt;<a name="line.13"></a>
<FONT color="green">014</FONT>     * }&lt;br/&gt;&lt;br/&gt;<a name="line.14"></a>
<FONT color="green">015</FONT>     * <a name="line.15"></a>
<FONT color="green">016</FONT>     * public interface StockPriceServiceAsync extends LoginableAsync{&lt;br/&gt;<a name="line.16"></a>
<FONT color="green">017</FONT>     * &amp;nbsp;&amp;nbsp;void getPrices(String[] symbols, AsyncCallback&lt;StockPrice[]&gt; callback);&lt;br/&gt; <a name="line.17"></a>
<FONT color="green">018</FONT>     * }&lt;br/&gt;&lt;br/&gt;<a name="line.18"></a>
<FONT color="green">019</FONT>     * <a name="line.19"></a>
<FONT color="green">020</FONT>     * public class StockWatcher implements EntryPoint {&lt;br/&gt;<a name="line.20"></a>
<FONT color="green">021</FONT>     * &amp;nbsp;&amp;nbsp;public void onModuleLoad() {&lt;br/&gt;<a name="line.21"></a>
<FONT color="green">022</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StockPriceServiceAsync stockPriceSvc = GWT.create(StockPriceService.class);&lt;br/&gt; <a name="line.22"></a>
<FONT color="green">023</FONT>     *     <a name="line.23"></a>
<FONT color="green">024</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StockPriceServiceAsync stockPriceSvcProxy = GWT.create(StockPriceServiceAsync.class);&lt;br/&gt;<a name="line.24"></a>
<FONT color="green">025</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LoginableService&lt;StockPriceServiceAsync&gt; loginService = (LoginableService&lt;StockPriceServiceAsync&gt;) stockPriceSvcProxy;&lt;br/&gt;&lt;br/&gt; <a name="line.25"></a>
<FONT color="green">026</FONT>     *     <a name="line.26"></a>
<FONT color="green">027</FONT>     * &amp;nbsp;&amp;nbsp;&amp;#47;*If not setRemoteService, proxy auto gerenate remote service by calling GWT.create(StockPriceServiceAsync.class)&lt;br/&gt;<a name="line.27"></a>
<FONT color="green">028</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;若是未設定setRemoteService，proxy 會自動叫用GWT.create(StockPriceServiceAsync.class) 產生一個*&amp;#47;&lt;br/&gt;<a name="line.28"></a>
<FONT color="green">029</FONT>     * &amp;nbsp;&amp;nbsp;loginService.setRemoteService(stockPriceSvc);&lt;br/&gt;&lt;br/&gt;<a name="line.29"></a>
<FONT color="green">030</FONT>     *<a name="line.30"></a>
<FONT color="green">031</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#47;*setting HasLoginHandler with a customed login dialog implements {@link HasLoginHandler}&lt;br/&gt;<a name="line.31"></a>
<FONT color="green">032</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;設定自定的登錄畫面(必須實做{@link HasLoginHandler})*&amp;#47;&lt;br/&gt;<a name="line.32"></a>
<FONT color="green">033</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;loginService.setHasLoginHandler(yourCustomedLoginDialog);&lt;br/&gt;&lt;br/&gt;<a name="line.33"></a>
<FONT color="green">034</FONT>     *     <a name="line.34"></a>
<FONT color="green">035</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#47;*Now call RPC from proxy wrapper stockPriceSvcProxy&lt;br/&gt;<a name="line.35"></a>
<FONT color="green">036</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;現在改用包裝後的stockPriceSvcProxy進行遠端呼叫*&amp;#47;&lt;br/&gt;  <a name="line.36"></a>
<FONT color="green">037</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;stockPriceSvcProxy.getPrices(symbols,new AsyncCallback&lt;StockPrice[]&gt;() {&lt;br/&gt;<a name="line.37"></a>
<FONT color="green">038</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#64;Override&lt;br/&gt;<a name="line.38"></a>
<FONT color="green">039</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void onSuccess(StockPrice[] result) {&lt;br/&gt;<a name="line.39"></a>
<FONT color="green">040</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br/&gt;<a name="line.40"></a>
<FONT color="green">041</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;<a name="line.41"></a>
<FONT color="green">042</FONT>     * &amp;#47;*&lt;dl&gt;&lt;dt&gt;You must handle&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;<a name="line.42"></a>
<FONT color="green">043</FONT>     *       &lt;tr&gt;&lt;td&gt;{@link com.gwt.ss.client.exceptions.GwtAccessDeniedException GwtAccessDeniedException}:&lt;/td&gt;<a name="line.43"></a>
<FONT color="green">044</FONT>     *           &lt;td&gt;Whenever user has not enough authority&lt;/td&gt; &lt;/tr&gt;<a name="line.44"></a>
<FONT color="green">045</FONT>     *       &lt;tr&gt;&lt;td&gt;{@link LoginCancelException}:&lt;/td&gt;<a name="line.45"></a>
<FONT color="green">046</FONT>     *           &lt;td&gt;User cancel login when login dialog box display&lt;/td&gt; &lt;/tr&gt;  <a name="line.46"></a>
<FONT color="green">047</FONT>     *       &lt;tr&gt;&lt;td colSpan=&amp;quot;2&amp;quot;&gt;Other exception&lt;/td&gt;&lt;/tr&gt; <a name="line.47"></a>
<FONT color="green">048</FONT>     *       &lt;/table&gt;&lt;/dd&gt;&lt;/dl&gt;<a name="line.48"></a>
<FONT color="green">049</FONT>     *       &lt;dl&gt;&lt;dt&gt;您必須自行處理以下錯誤:&lt;/dt&gt;&lt;dd&gt;&lt;table&gt;<a name="line.49"></a>
<FONT color="green">050</FONT>     *       &lt;tr&gt;&lt;td&gt;{@link com.gwt.ss.client.exceptions.GwtAccessDeniedException GwtAccessDeniedException}:&lt;/td&gt;<a name="line.50"></a>
<FONT color="green">051</FONT>     *           &lt;td&gt;用戶權限不足時&lt;/td&gt; &lt;/tr&gt;<a name="line.51"></a>
<FONT color="green">052</FONT>     *       &lt;tr&gt;&lt;td&gt;{@link LoginCancelException}:&lt;/td&gt;<a name="line.52"></a>
<FONT color="green">053</FONT>     *           &lt;td&gt;登錄畫面出現時，用戶取消登錄&lt;/td&gt; &lt;/tr&gt;  <a name="line.53"></a>
<FONT color="green">054</FONT>     *       &lt;tr&gt;&lt;td colSpan=&amp;quot;2&amp;quot;&gt;與其它所有錯誤&lt;/td&gt;&lt;/tr&gt; <a name="line.54"></a>
<FONT color="green">055</FONT>     *       &lt;/table&gt;&lt;/dd&gt;&lt;/dl&gt;*&amp;#47;&lt;br/&gt;   <a name="line.55"></a>
<FONT color="green">056</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#64;Override&lt;br/&gt;<a name="line.56"></a>
<FONT color="green">057</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void onFailure(Throwable caught) {&lt;br/&gt;<a name="line.57"></a>
<FONT color="green">058</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;... <a name="line.58"></a>
<FONT color="green">059</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;      <a name="line.59"></a>
<FONT color="green">060</FONT>     * &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;            <a name="line.60"></a>
<FONT color="green">061</FONT>     * &amp;nbsp;&amp;nbsp;}&lt;br/&gt;  <a name="line.61"></a>
<FONT color="green">062</FONT>     * }&lt;br/&gt;        <a name="line.62"></a>
<FONT color="green">063</FONT>     *       <a name="line.63"></a>
<FONT color="green">064</FONT>     * @author Kent Yeh<a name="line.64"></a>
<FONT color="green">065</FONT>     */<a name="line.65"></a>
<FONT color="green">066</FONT>    public interface LoginableAsync {<a name="line.66"></a>
<FONT color="green">067</FONT>    }<a name="line.67"></a>




























































</PRE>
</BODY>
</HTML>
